import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
  {
    title: '询报价编码',
    dataIndex: 'rfqCode',
  },
  {
    title: '询报价名称',
    dataIndex: 'rfqName',
  },
  {
    title: '总价',
    dataIndex: 'goodsAmount',
  },
  {
    title: '自定义报价主题',
    dataIndex: 'rfqTheme',
  },
  {
    title: '审核人',
    dataIndex: 'auditUser',
  },
  {
    title: '审核时间',
    dataIndex: 'auditTime',
  },
  {
    title: '审核状态',
    dataIndex: 'auditStatus',
  },
  {
    title: '审核原因',
    dataIndex: 'auditReason',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '询报价编码',
    field: 'rfqCode',
    component: 'Input',
    componentProps: {
      placeholder: '请输入询报价编码',
    },
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '报价编码',
    field: 'rfqCode',
    component: 'Input',
    componentProps: {
      placeholder: '系统自动生成',
      disabled: true, // 编码由系统生成，用户不可编辑
    },
    // 添加生成规则说明
    helpMessage: ['编码采用生成规则'],
  },
  {
    label: '询报价名称',
    field: 'rfqName',
    component: 'Input',
  },
  {
    label: '总价',
    field: 'goodsAmount',
    component: 'InputNumber',
    componentProps: {
      style: { width: '100%' }, // Ensure consistent width
      placeholder: '请输入总价',
    },
    rules: [
      {
        required: true,
        message: '请输入总价',
      },
    ],
  },
  {
    label: '自定义报价主题',
    field: 'rfqTheme',
    component: 'Input',
    componentProps: {
      placeholder: '点击选择报价主题',
      readOnly: true, // 设置为只读，点击弹窗选择
    },
    slot: 'rfqThemeSelector', // 使用插槽自定义渲染
  },
  {
    label: '审核人',
    field: 'auditUser',
    component: 'Input',
  },
  {
    label: '审核时间',
    field: 'auditTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD hh:mm:ss',
    },
  },
  {
    label: '审核状态',
    field: 'auditStatus',
    component: 'Input',
  },
  {
    label: '审核原因',
    field: 'auditReason',
    component: 'Input',
  },
];
